cmake_minimum_required(VERSION 3.0.0)
project(helloWorldOfOpenGl)

set(CMAKE_CXX_STANDARD 11)


# Used for usage and error messages in the program.
ADD_COMPILE_DEFINITIONS(ASSIMP_VERSION="${ASSIMP_VERSION}")
ADD_COMPILE_DEFINITIONS(PROJECT_NAME="${SAMPLE_PROJECT_NAME}")

# Finding GLM with CMake
set(glm_DIR ${PROJECT_SOURCE_DIR}/include/glm-0.9.9.8/cmake/glm)  
find_package(glm REQUIRED) 

# 添加头文件
set(GLAD_H ${PROJECT_SOURCE_DIR}/include)
#set(GLFW_H /usr/local/include)
set(GLFW_H ${PROJECT_SOURCE_DIR}/include)

set(ASSIMP_H ${PROJECT_SOURCE_DIR}/include)

set(SRC_H ${PROJECT_SOURCE_DIR}/src/include)
include_directories(${GLAD_H} ${GLFW_H} ${ASSIMP_H} ${SRC_H})

#添加目标链接
#set(GLFW_LINK /usr/local/lib/libglfw.3.dylib)
#set(GLFW_LINK /usr/local/axe/lib/libglfw.3.dylib)
set(GLFW_LINK ${PROJECT_SOURCE_DIR}/libs/glfw/libglfw.3.dylib)
link_libraries(${GLFW_LINK})

set(ASSIMP_LINK ${PROJECT_SOURCE_DIR}/libs/assimp/libassimp.5.0.1.dylib)
link_libraries(${ASSIMP_LINK})

#执行编译命令
set(SOURCES src/main.cpp 
    src/glad.c 
    src/include/stb_image.h
    src/include/List.h          src/libs/List.c
    src/include/FileUtil.h      src/libs/FileUtil.c
    src/include/Camera.h        src/libs/Camera.cpp
    src/include/MyShader.h      src/libs/MyShader.cpp
    src/include/RenderUtil.h    src/libs/RenderUtil.cpp

    src/test/SimpleTestOpenGl.h     src/test/SimpleTestOpenGl.cpp
    src/include/Mesh.h src/libs/Mesh.cpp
        src/libs/Model.cpp src/include/Model.h src/test/TestAdvanceData_4_7.cpp src/test/TestAdvanceData_4_7.h)



#set(SRC_LIST main.c)
#add_executable(helloWorldOfOpenGl ${SRC_LIST})
add_executable(helloWorldOfOpenGl ${SOURCES})

# 链接系统的 OpenGL框架
if(APPLE) 
    target_link_libraries(helloWorldOfOpenGl "-framework OpenGL")
endif()

# 链接glm库
target_link_libraries(helloWorldOfOpenGl glm::glm)

include(CTest)
enable_testing()

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)